home *** CD-ROM | disk | FTP | other *** search
/ KeyGen Studio 2002 / KeyGen_Studio_2002.iso / Tutorials / Code Inside / Tut19.txt < prev    next >
Encoding:
Text File  |  2001-09-21  |  12.0 KB  |  263 lines

  1. ******************************************************************************************************************************************
  2.                     CrackMe #2
  3. ******************************************************************************************************************************************
  4.  
  5. Author:        n0p3x
  6. Protection:    Name / Serial
  7. URL:        http://www.phrozencrew.co.uk/crackme2.zip
  8. Tools:        SoftICE V4.05
  9.         W32Dasm V8.93
  10.         Hex-Editor
  11.  
  12.  
  13. --->    Intro...
  14.  
  15. Welcome to my next Tutorial !!!
  16. This time a little CrackMe from n0p3x, a very easy one ;)
  17. We've got two objectives:
  18.  
  19. 1.    Remove the NAG
  20. 2.    Find a valid Serial for your Name
  21.  
  22.  
  23. --->    Let's Begin... (Part 1 - Remove the NAG)
  24.  
  25. Open the CrackMe and you'll get a Message Box (The NAG) saying:
  26.  
  27. "This is a shareware version, blah, blah, please pay me, blah, blah"
  28.  
  29. Hehe ;)
  30. Now click "Ok" and you'll get in the main window, but we need to remove the NAG first so press
  31. the button "Exit" and open the CrackMe in W32Dasm.
  32. Then click on "Strn Ref" (String Data References) and double click on the line:
  33.  
  34. "This is a shareware version, blah,"
  35.  
  36. And you'll see this:
  37.  
  38. ------------------------------------------------------------------------------------------------------------------------------------------
  39.  
  40. :004011B1 55                      push ebp
  41. :004011B2 8BEC                    mov ebp, esp
  42. :004011B4 6A10                    push 00000010                <--- Here we'll patch it into a "jmp"
  43.  
  44. * Possible StringData Ref from Data Obj ->"Nag Nag Nag!"
  45.                                   |
  46. :004011B6 688C214000              push 0040218C
  47.  
  48. * Possible StringData Ref from Data Obj ->"This is a shareware version, blah, "
  49.                                         ->"blah, please pay me, blah, blah"
  50.                                   |
  51. :004011BB 6849214000              push 00402149
  52. :004011C0 6A00                    push 00000000
  53.  
  54. * Reference To: USER32.MessageBoxA, Ord:0000h
  55.                                   |
  56. :004011C2 E8DF030000              Call 004015A6
  57. :004011C7 6A00                    push 00000000
  58. :004011C9 68EC104000              push 004010EC
  59. :004011CE 6A00                    push 00000000
  60.  
  61. * Possible Reference to Dialog: DialogID_0001 
  62.                                   |
  63. :004011D0 6A01                    push 00000001
  64. :004011D2 FF7508                  push [ebp+08]
  65.  
  66. * Reference To: USER32.DialogBoxParamA, Ord:0000h
  67.                                   |
  68. :004011D5 E8C0030000              Call 0040159A
  69. :004011DA 33C0                    xor eax, eax
  70. :004011DC 5D                      pop ebp
  71. :004011DD C21000                  ret 0010
  72.  
  73. ------------------------------------------------------------------------------------------------------------------------------------------
  74.  
  75. Ok, as you'll probably notice this process isn't been called from anywhere :)
  76. W32Dasm is just too stupid to show that, offcourse it has been called from somewhere, it's not the OEP ;)
  77. Anyway we're going to jump over the Message Box.
  78. You can NOP out the whole Message Box process but that's too lame ;)
  79. The Message Box process starts at "6A10" offset 004011B4.
  80. So we're going to replace "6A10" with "EB11" (jmp).
  81. Why "11" ???
  82. Just count the opcodes after "6A10" (which will be EB11 same size) till your after the "Call MessageBoxA" :)
  83. I assume you know how to change this in your Hex-Editor, otherwise read my previous Tutorials ;)
  84. On to the next Part.
  85.  
  86.  
  87. --->    Let's Begin... (Part 2 - Find a valid Serial for your Name)
  88.  
  89. Open the CrackMe (if you've done everything right no NAG this time ;) and fill in something, i've used:
  90.  
  91. Name:        CoDeInSiDe    ---> you can only use 10 chars, so i couldn't use CoDe_InSiDe :(
  92. Serial:        1234567890
  93.  
  94. Then get into SoftICE (CTRL+D) and type "bpx hmemcpy" followed by "enter" then out of SoftICE (CTRL+D)
  95. and press the button "Ok" and SoftICE should popup.
  96. Now type "BC *" to clear the breakpoint and press (F12) 9 times and you'll see this:
  97.  
  98. ------------------------------------------------------------------------------------------------------------------------------------------
  99.  
  100. :00401182 6A0B                    push 0000000B
  101. :00401184 8D4DF4                  lea ecx, dword ptr [ebp-0C]
  102. :00401187 51                      push ecx
  103.  
  104. * Possible Reference to Dialog: DialogID_0001, CONTROL_ID:0067, ""
  105.                                   |
  106. :00401188 6A67                    push 00000067
  107. :0040118A FF7508                  push [ebp+08]
  108.  
  109. * Reference To: USER32.GetDlgItemTextA, Ord:0000h
  110.                                   |
  111. :0040118D E8FC030000              Call 0040158E
  112. :00401192 8D45F4                  lea eax, dword ptr [ebp-0C]        <--- EAX now points to our "Fake" Serial
  113. :00401195 50                      push eax                <--- Save EAX
  114. :00401196 8D55E8                  lea edx, dword ptr [ebp-18]        <--- EDX now points to our Name
  115. :00401199 52                      push edx                <--- Save EDX
  116. :0040119A E8DDFEFFFF              call 0040107C                <--- Check this CALL
  117.  
  118. ------------------------------------------------------------------------------------------------------------------------------------------
  119.  
  120. Ok, Now get into the "CALL 0040107C" and you'll see this:
  121.  
  122. ------------------------------------------------------------------------------------------------------------------------------------------
  123.  
  124. :0040107C 55                      push ebp
  125. :0040107D 8BEC                    mov ebp, esp
  126. :0040107F 83C4F4                  add esp, FFFFFFF4
  127. :00401082 6A0A                    push 0000000A
  128. :00401084 8D45F4                  lea eax, dword ptr [ebp-0C]
  129. :00401087 50                      push eax
  130. :00401088 FF7508                  push [ebp+08]                <--- Points to our Name
  131.  
  132. * Reference To: KERNEL32.lstrlenA, Ord:0000h
  133.                                   |
  134. :0040108B E8F2040000              Call 00401582                <--- Get the Length
  135. :00401090 50                      push eax                <--- Save the Length
  136.  
  137. * Reference To: cw3220._itoa, Ord:0000h
  138.                                   |
  139. :00401091 E8C8040000              Call 0040155E                <--- Here's the Algo
  140. :00401096 83C40C                  add esp, 0000000C
  141.  
  142. * Possible StringData Ref from Data Obj ->"999081"
  143.                                   |
  144. :00401099 6874204000              push 00402074                <--- Save this new string "999081"
  145. :0040109E 8D55F4                  lea edx, dword ptr [ebp-0C]        <--- New Serial (not completely)
  146. :004010A1 52                      push edx                <--- Save it
  147.  
  148. * Reference To: cw3220._strcat, Ord:0000h
  149.                                   |
  150. :004010A2 E8A5040000              Call 0040154C                <--- Add them together
  151. :004010A7 83C408                  add esp, 00000008
  152. :004010AA 8D4DF4                  lea ecx, dword ptr [ebp-0C]        <--- ECX now points to our New Serial
  153. :004010AD 51                      push ecx                <--- Save it
  154. :004010AE FF750C                  push [ebp+0C]                <--- Save our "Fake" Serial
  155.  
  156. * Reference To: KERNEL32.lstrcmpA, Ord:0000h
  157.                                   |
  158. :004010B1 E8C0040000              Call 00401576                <--- Compare them
  159. :004010B6 85C0                    test eax, eax                <--- Test if EAX is 00
  160. :004010B8 7518                    jne 004010D2                <--- If not we jump and get the Bad Guy message, else continue
  161.  
  162. ------------------------------------------------------------------------------------------------------------------------------------------
  163.  
  164. Ok, first it gets the Length of our Name, then it goes to the Algo (explained below).
  165. Then it gets another string "999081" (the Serial for the previous CrackMe ;) and adds it to our New Serial.
  166. And then it just Compares the New Serial with our "Fake" Serial with the API "lstrcmpA".
  167. The API returns 00000000 if their equal, otherwise it returns 00000001.
  168.  
  169. 00000000 - Good Guy message
  170. 00000001 - Bad Guy message
  171.  
  172. If you want to patch this just NOP the "jne 004010D2" :)
  173. Now i'll explain the Algo (only the Algo) it's located in "Cw3220.dll" so get in the "Call 0040155E" and trace a bit till you see this:
  174.  
  175. ------------------------------------------------------------------------------------------------------------------------------------------
  176.  
  177. ESI holds the length of our Name
  178.  
  179. :0041573B 8BC6                    mov eax, esi                <--- Move ESI in EAX
  180. :0041573D 33D2                    xor edx, edx                <--- XOR EDX which is now 00
  181. :0041573F F7F7                    div edi                <--- Divide with EDI
  182. :00415741 8811                    mov byte ptr [ecx], dl        <--- Move DL in [ECX]
  183. :00415743 41                      inc ecx                <--- ECX +1
  184. :00415744 8BC6                    mov eax, esi                <--- Move ESI in EAX
  185. :00415746 33D2                    xor edx, edx                <--- XOR EDX which is now 00
  186. :00415748 F7F7                    div edi                <--- Divide with EDI
  187. :0041574A 8BF0                    mov esi, eax                <--- Move EAX in ESI
  188. :0041574C 85C0                    test eax, eax                <--- Test if EAX is 00
  189. :0041574E 75EB                    jne 0041573B                <--- If not repeat this loop, else continue
  190. :00415750 EB17                    jmp 00415769                <--- Jump to Compare
  191.  
  192. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  193. |:0041576E(C)
  194. |
  195. :00415752 49                      dec ecx                <--- ECX -1
  196. :00415753 8A01                    mov al, byte ptr [ecx]        <--- Move a byte from [ECX] in AL
  197. :00415755 3C0A                    cmp al, 0A                <--- Compare AL with 0000000A
  198. :00415757 7D08                    jge 00415761                <--- Jump if equal or greater
  199. :00415759 83C030                  add eax, 00000030            <--- ADD 30 to AL
  200. :0041575C 8803                    mov byte ptr [ebx], al        <--- Move AL in [EBX]
  201. :0041575E 43                      inc ebx                <--- EBX +1
  202. :0041575F EB08                    jmp 00415769                <--- Jump to Compare
  203.  
  204. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  205. |:00415757(C)
  206. |
  207. :00415761 024518                  add al, byte ptr [ebp+18]        <--- ADD a byte from [EBP+18] in AL
  208. :00415764 04F6                    add al, F6                <--- ADD F6 in AL
  209. :00415766 8803                    mov byte ptr [ebx], al        <--- Move AL in [EBX]
  210. :00415768 43                      inc ebx                <--- EBX +1
  211.  
  212. * Referenced by a (U)nconditional or (C)onditional Jump at Addresses:
  213. |:00415750(U), :0041575F(U)
  214. |
  215. :00415769 8D55DC                  lea edx, dword ptr [ebp-24]        <--- Point EDX to the end of our New Serial
  216. :0041576C 3BCA                    cmp ecx, edx                <--- Compare EDX with ECX
  217. :0041576E 75E2                    jne 00415752                <--- If not equal repeat loop, else continue
  218.  
  219. * Referenced by a (U)nconditional or (C)onditional Jump at Addresses:
  220. |:00415721(C), :00415726(C)
  221. |
  222. :00415770 C60300                  mov byte ptr [ebx], 00        <--- Move 00 at the end of our New Serial
  223. :00415773 8B450C                  mov eax, dword ptr [ebp+0C]
  224. :00415776 5F                      pop edi
  225. :00415777 5E                      pop esi
  226. :00415778 5B                      pop ebx
  227. :00415779 8BE5                    mov esp, ebp
  228. :0041577B 5D                      pop ebp
  229. :0041577C C3                      ret
  230.  
  231. ------------------------------------------------------------------------------------------------------------------------------------------
  232.  
  233. As you can see at this place the Algo isn't doing anything with the Chars of your Name only the length :)
  234. So it takes the Length of your Name and DIV's it with 0000000A, then it places the remainder in some place.
  235. Then it DIV's again with 0000000A and places the result (in EAX) in ESI.
  236. Then it repeats again.
  237.  
  238. When it is done it takes the last value (of the New values) and ADD's 30 and puts it in some place till all done.
  239. Then it repeats again.
  240.  
  241. After all this it goes back to the CrackMe's Code and puts "999081" behind the New Serial.
  242. That's all my final New Serial was:
  243.  
  244. Name:        CoDeInSiDe
  245. Serial:        10999081
  246.  
  247. It's very easy ;)
  248.  
  249.  
  250. --->    Greetings...
  251.  
  252. Everyone from TrickSoft            (www.TrickSoft.net)
  253. Everyone from Cracking4Newbies        (www.Cracking4Newbies.com)
  254. Everyone from Keygenning4Newbies    (Keygenning4Newbies.cjb.net)
  255. And You...
  256.  
  257.             Don't trust the Outside, trust the InSiDe !!!
  258.  
  259.                       Cya...
  260.  
  261.                     CoDe_InSiDe
  262.  
  263. Email:    code.inside@home.nl